package com.ruoyi.binding.controller;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.binding.domain.*;
import com.ruoyi.binding.domain.JDP.Params.*;
import com.ruoyi.binding.domain.JDP.Result.AllocateResult;
import com.ruoyi.binding.domain.JDP.Result.QueryInsideRecOrderResult;
import com.ruoyi.binding.domain.JDP.Tools.OkHttpSessionClient;
import com.ruoyi.binding.mapper.MhOrderInfoMapper;
import com.ruoyi.binding.service.*;
import com.ruoyi.binding.service.impl.MhBindingServiceImpl;
import com.ruoyi.binding.service.impl.MhJDPServiceImpl;
import com.ruoyi.binding.service.impl.MhOrderInfoServiceImpl;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单指派Controller
 *
 * @author Ekko
 * @date 2025-06-30
 */
@RestController
@RequestMapping("/order/allocate")
public class MhOrderAllocateController extends BaseController {
    @Autowired
    private IMhOrderAllocateService mhOrderAllocateService;


    @Autowired
    private IMhSecJDPService mhJDPService;

    @Autowired
    IMhBindingService mhBindingService;
    @Autowired
    private MhBindingServiceImpl mhBindingServiceImpl;

    @Autowired
    private MhOrderInfoMapper mhOrderInfoMapper;

    @Autowired
    private ISysDeptService DeptService;

    @Autowired
    private IMhOrderRemoteService mhOrderRemoteService;

    @Autowired
    private IMhUpstreamStudioConfigService mhUpstreamStudioConfigService;


    /**
     * 根据单号查询内部抢单大厅订单
     */

    @PreAuthorize("@ss.hasPermi('order:allocate:list')")
    @GetMapping("/queryInsideRecOrder/{orderViewId}")
    public AjaxResult queryInsideRecOrder(@PathVariable("orderViewId") String orderViewId) throws Exception {
        logger.info("根据单号查询管理订单内未分配的订单");
        //查询当前部门所设置的参数
        String dispatchMode = getDeptDispatchMode(SecurityUtils.getDeptId());
        logger.info("当前部门的调度模式：{}", dispatchMode);
        if (StringUtils.isEmpty(dispatchMode)) {
            logger.error("用户所在部门未配置派单模式，无法执行自动派单任务");
            throw new ServiceException("用户所在部门未配置派单模式");
        }
        logger.info("当前部门dispatchMode: {}", dispatchMode);
        if (dispatchMode.equals("1")) {
            logger.info("部门dispatchMode为1，使用本地发送");
            MhOrderAllocate query = new MhOrderAllocate();
            query.setOrderIdView(orderViewId);
            MhOrderAllocate result = mhOrderAllocateService.selectMhOrderAllocateList(query).stream()
                    .findFirst()
                    .orElse(null);

            if (result != null) {

                BigDecimal recFeeOriginal = result.getPrice(); // 原始订单价格
                logger.info("查询到订单原始价格：{}", recFeeOriginal);

                // 计算管理员抽成后的放单价格
                Long userId = SecurityUtils.getUserId();
                MhBinding mhBinding = mhBindingService.selectMhBindingByUserId(userId);
                if (mhBinding == null) {
                    logger.warn("未配置绑定信息，无法计算放单价格");
                    result.setRecFee(new BigDecimal("0"));
                } else {
                    BigDecimal adminRatio = calculateAdminRatio(mhBinding, result.getGameName());
                    BigDecimal adminFactor = BigDecimal.ONE.subtract(adminRatio.divide(BigDecimal.valueOf(100)));
                    BigDecimal originalFee = recFeeOriginal != null ? recFeeOriginal : BigDecimal.ZERO;
                    BigDecimal finalFee = originalFee.multiply(adminFactor).setScale(2, BigDecimal.ROUND_HALF_UP);

                    logger.info("管理员抽成比例：{}%，计算后的放单价格：{}", adminRatio, finalFee);
                    result.setRecFee(finalFee);
                }
                logger.info("查询到的项目内容：{}", result.getProject());
                return AjaxResult.success(result);
            } else {
                return AjaxResult.error("未找到订单/订单已经被接走");
            }
        } else if (dispatchMode.equals("0")) {
            logger.info("部门dispatchMode为0，使用JDP发送");
            //先在mhOrderRemote中查询出baseUrl
            MhOrderRemote query = new MhOrderRemote();
            query.setOrderIdView(orderViewId);
            String baseUrl = mhOrderRemoteService.selectMhOrderRemoteList(query).stream()
                    .findFirst()
                    .map(MhOrderRemote::getAssUserName)
                    .orElseThrow(() -> new ServiceException("未找到对应的远程订单配置"));
            //根据baseurl查询表中的配置信息
            logger.info("查询到的远程订单配置baseUrl: {}", baseUrl);
            MhUpstreamStudioConfig queryConfig = new MhUpstreamStudioConfig();
            queryConfig.setStudioUrl(baseUrl);
            queryConfig.setDeptId(SecurityUtils.getDeptId());
            MhUpstreamStudioConfig config = mhUpstreamStudioConfigService.selectConfigByDept(queryConfig).stream()
                    .findFirst()
                    .orElseThrow(() -> new ServiceException("未找到对应的上游工作室配置"));
            logger.info("使用上游工作室配置：{}", config);

            OkHttpSessionClient proClient = new OkHttpSessionClient();

            mhJDPService.login(proClient, config.getDeptId(), config.getStudioUrl(), config.getUsername(), config.getPassword());

            // 1. 查询订单信息
            JDPProOrderParam jdpParam = new JDPProOrderParam();
            jdpParam.setKey(orderViewId);
            MhOrderAllocate result = new MhOrderAllocate();
            JSONObject orderResponse = mhJDPService.queryInsideRecOrder(proClient, jdpParam);

            JSONArray orderData = orderResponse.getJSONArray("data");
            if (orderData == null || orderData.isEmpty()) {
                return AjaxResult.error("未找到订单或订单已被接走");
            }

            JSONObject firstOrder = orderData.getJSONObject(0);
            result.setGameName(firstOrder.getString("gameName"));
            result.setPrice(new BigDecimal(firstOrder.getString("recFee")));
            result.setOrderId(firstOrder.getString("orderId"));
            result.setOrderIdView(firstOrder.getString("orderIdView"));
            result.setProject(firstOrder.getString("project"));
            result.setOrderSta(firstOrder.getString("orderSta"));

            logger.info("查询到订单：游戏名={}，金额={}，订单ID={}", result.getGameName(), result.getPrice(), result.getOrderId());

            BigDecimal recFeeOriginal = result.getPrice(); // 原始订单价格
            logger.info("查询到订单原始价格：{}", recFeeOriginal);
            // 计算管理员抽成后的放单价格
            Long userId = SecurityUtils.getUserId();
            MhBinding mhBinding = mhBindingService.selectMhBindingByUserId(userId);
            if (mhBinding == null) {
                logger.warn("未配置绑定信息，无法计算放单价格");
                result.setRecFee(new BigDecimal("0"));
            } else {
                BigDecimal adminRatio = calculateAdminRatio(mhBinding, result.getGameName());
                BigDecimal adminFactor = BigDecimal.ONE.subtract(adminRatio.divide(BigDecimal.valueOf(100)));
                BigDecimal originalFee = recFeeOriginal != null ? recFeeOriginal : BigDecimal.ZERO;
                BigDecimal finalFee = originalFee.multiply(adminFactor).setScale(2, BigDecimal.ROUND_HALF_UP);

                logger.info("管理员抽成比例：{}%，计算后的放单价格：{}", adminRatio, finalFee);
                result.setRecFee(finalFee);
            }
            logger.info("查询到的项目内容：{}", result.getProject());
            return AjaxResult.success(result);

    } else {
        logger.error("用户所在部门dispatchMode配置错误，无法执行自动派单任务");
        throw new ServiceException("用户所在部门派单模式配置错误，联系管理员");
    }

}

/**
 * 计算管理员抽成比例
 *
 * @param mhBinding 当前用户绑定信息，包含游戏价格比例
 * @param gameName  订单的游戏名
 * @return 管理员抽成比例（百分比，BigDecimal，例如返回10表示10%）
 */
private BigDecimal calculateAdminRatio(MhBinding mhBinding, String gameName) {
    BigDecimal adminRatio = BigDecimal.ZERO;

    if (mhBinding.getMhUserGamePriceList() != null) {
        for (MhUserGamePrice price : mhBinding.getMhUserGamePriceList()) {
            if (price.getGameCategoryName().trim().equalsIgnoreCase(gameName)) {
                adminRatio = price.getPriceRatio();
                break;
            }
        }
    }

    logger.info("计算管理员抽成比例 -> 游戏名: {}, 管理员抽成比例: {}%", gameName, adminRatio);
    return adminRatio;
}


//内部抢单大厅接单以及指派
@PreAuthorize("@ss.hasPermi('order:allocate:list')")
@PostMapping("/toCus")
public AjaxResult takeOrder(@RequestBody JDPProTakeOrderParam param) throws Exception {
    logger.info("开始管理订单接单以及指派");

    //查询当前部门所设置的参数
    String dispatchMode = getDeptDispatchMode(SecurityUtils.getDeptId());
    logger.info("当前部门的调度模式：{}", dispatchMode);
    if (StringUtils.isEmpty(dispatchMode)) {
        logger.error("用户所在部门未配置派单模式，无法执行自动派单任务");
        throw new ServiceException("用户所在部门未配置派单模式");
    }
    logger.info("当前部门dispatchMode: {}", dispatchMode);
    if (dispatchMode.equals("1")) {
        logger.info("部门dispatchMode为1，使用本地模式接单");
        OkHttpSessionClient client = new OkHttpSessionClient();
        mhJDPService.login(client);
        // 1. 查询订单信息
        MhOrderAllocate query = new MhOrderAllocate();
        query.setOrderIdView(param.getId());
        MhOrderAllocate order = mhOrderAllocateService.selectMhOrderAllocateList(query).stream()
                .findFirst()
                .orElse(null);
        if (order == null) {
            return AjaxResult.error("未找到订单/订单已经被接走");
        }

        Long userIdTemp = Long.valueOf(param.getWorkerId().split("_")[0]);
        String workerIdTemp = param.getWorkerId().split("_")[1];
//      根据用户id查用户名并且拼接workerIdTemp
        String workerName = mhBindingService.selectMhBindingByUserId(userIdTemp).getSuLoginAcc() + "_" + workerIdTemp;


        // 3. 获取当前用户绑定信息
        Long userId = Objects.equals(SecurityUtils.getUserId(), userIdTemp) ? SecurityUtils.getUserId() : userIdTemp;
        MhBinding mhBinding = mhBindingService.selectMhBindingByUserId(userId);
        if (mhBinding == null) {
            return AjaxResult.error("未配置绑定信息，请先联系管理员完成账户绑定");
        }
        logger.info("当前用户绑定信息：{}", mhBinding);

        // 4. 计算综合抽成后的价格
        BigDecimal lastFee = mhOrderAllocateService.calculateFinalFee(mhBinding, userId, order.getGameName(), order.getPrice().toString());


        // 6. 指派订单
        JDPCusStrParameter strParam = new JDPCusStrParameter();
        strParam.setUserId(mhBinding.getSuUid());
        strParam.setUsername(mhBinding.getSuUserName());
        strParam.setFee(lastFee.toString());

        JDPCusAllocateParam allocateParam = new JDPCusAllocateParam();
        allocateParam.setOrderId(order.getOrderId());
        allocateParam.setStrParameter(List.of(strParam));

        String allocateMsg = mhJDPService.allocate(client, allocateParam).getString("msg");
        logger.info("指派结果：{}", allocateMsg);

        // 7. 设置机位
        JDPCusSetUserParam setUserParam = new JDPCusSetUserParam();
        setUserParam.setOrderId(order.getOrderId());
        setUserParam.setJiwei(workerName);
        String setUserMsg = mhJDPService.setUser(client, setUserParam).getString("msg");
        logger.info("设置机位结果：{}", setUserMsg);

        // 8. 更新订单状态
        JDPSetOrderStaParam setOrderStaParam = new JDPSetOrderStaParam();
        setOrderStaParam.setOrderId(order.getOrderId());
        String updateOrderStatusMsg = mhJDPService.updateOrderStatus(client, setOrderStaParam).getString("msg");
        logger.info("更新订单状态结果：{}", updateOrderStatusMsg);

        // 9. 返回结果
        AllocateResult result = new AllocateResult();
        result.setAllocateMsg(allocateMsg);
        result.setSetUserMsg(setUserMsg);
        result.setUpdateOrderStatusMsg(updateOrderStatusMsg);
        result.setAllocatePrice(lastFee.toPlainString());


        MhOrderInfo orderInfo = new MhOrderInfo();
        orderInfo.setOrderId(order.getOrderId());
        orderInfo.setOrderSta("已指派");
        mhOrderInfoMapper.insertMhOrderInfo(orderInfo);

        client.clearCurrentUser();
        return AjaxResult.success(result);
    } else if (dispatchMode.equals("0")) {
        logger.info("部门dispatchMode为0，使用JDP模式接单");
        //先在mhOrderRemote中查询出baseUrl
        MhOrderRemote query = new MhOrderRemote();
        query.setOrderIdView(param.getId());
        String baseUrl = mhOrderRemoteService.selectMhOrderRemoteList(query).stream()
                .findFirst()
                .map(MhOrderRemote::getAssUserName)
                .orElseThrow(() -> new ServiceException("未找到对应的远程订单配置"));
        //根据baseurl查询表中的配置信息
        MhUpstreamStudioConfig queryConfig = new MhUpstreamStudioConfig();
        queryConfig.setStudioUrl(baseUrl);
        queryConfig.setDeptId(SecurityUtils.getDeptId());
        MhUpstreamStudioConfig config = mhUpstreamStudioConfigService.selectConfigByDept(queryConfig).stream()
                .findFirst()
                .orElseThrow(() -> new ServiceException("未找到对应的上游工作室配置"));

        OkHttpSessionClient proClient = new OkHttpSessionClient();

        mhJDPService.login(proClient, config.getDeptId(), config.getStudioUrl(), config.getUsername(), config.getPassword());

        // 1. 查询订单信息
        JDPProOrderParam jdpParam = new JDPProOrderParam();
        jdpParam.setKey(param.getId());
        JSONObject orderResponse = mhJDPService.queryInsideRecOrder(proClient, jdpParam);

        JSONArray orderData = orderResponse.getJSONArray("data");
        if (orderData == null || orderData.isEmpty()) {
            return AjaxResult.error("未找到订单或订单已被接走");
        }

        JSONObject firstOrder = orderData.getJSONObject(0);
        String gameName = firstOrder.getString("gameName");
        String fee = firstOrder.getString("recFee");
        String orderId = firstOrder.getString("orderId");

        logger.info("查询到订单：游戏名={}，金额={}，订单ID={}", gameName, fee, orderId);

        // 2. 接单
        param.setId(orderId);
        String takeOrderMsg = mhJDPService.takeOrder(proClient, param).getString("msg");
        logger.info("接单结果：{}", takeOrderMsg);

        if (!takeOrderMsg.contains("接单成功")) {
            // 如果接单失败直接返回
            return AjaxResult.error("接单失败：" + takeOrderMsg);
        }

        Long userIdTemp = Long.valueOf(param.getWorkerId().split("_")[0]);
        String workerIdTemp = param.getWorkerId().split("_")[1];
//      根据用户id查用户名并且拼接workerIdTemp
        String workerName = mhBindingService.selectMhBindingByUserId(userIdTemp).getSuLoginAcc() + "_" + workerIdTemp;

        // 3. 获取当前用户绑定信息
        Long userId = Objects.equals(SecurityUtils.getUserId(), userIdTemp) ? SecurityUtils.getUserId() : userIdTemp;
        MhBinding mhBinding = mhBindingService.selectMhBindingByUserId(userId);
        if (mhBinding == null) {
            return AjaxResult.error("未配置绑定信息，请先联系管理员完成账户绑定");
        }
        logger.info("当前用户绑定信息：{}", mhBinding);

        // 4. 计算综合抽成后的价格
        BigDecimal lastFee = mhOrderAllocateService.calculateFinalFee(mhBinding, userId, gameName, fee);


        OkHttpSessionClient subClient = new OkHttpSessionClient();
        mhJDPService.login(subClient);
        // 5. 接单成功后等待订单流转，带重试查询真实订单ID
        String orderIdReal = queryRealOrderIdWithRetry(subClient, jdpParam.getKey(), gameName);

        // 6. 指派订单
        JDPCusStrParameter strParam = new JDPCusStrParameter();
        strParam.setUserId(mhBinding.getSuUid());
        strParam.setUsername(mhBinding.getSuUserName());
        strParam.setFee(lastFee.toString());

        JDPCusAllocateParam allocateParam = new JDPCusAllocateParam();
        allocateParam.setOrderId(orderIdReal);
        allocateParam.setStrParameter(List.of(strParam));

        String allocateMsg = mhJDPService.allocate(subClient, allocateParam).getString("msg");
        logger.info("指派结果：{}", allocateMsg);

        // 7. 设置机位
        JDPCusSetUserParam setUserParam = new JDPCusSetUserParam();
        setUserParam.setOrderId(orderIdReal);
        setUserParam.setJiwei(workerName);
        String setUserMsg = mhJDPService.setUser(subClient, setUserParam).getString("msg");
        logger.info("设置机位结果：{}", setUserMsg);

        // 8. 更新订单状态
        JDPSetOrderStaParam setOrderStaParam = new JDPSetOrderStaParam();
        setOrderStaParam.setOrderId(orderIdReal);
        String updateOrderStatusMsg = mhJDPService.updateOrderStatus(subClient, setOrderStaParam).getString("msg");
        logger.info("更新订单状态结果：{}", updateOrderStatusMsg);

        // 9. 返回结果
        AllocateResult result = new AllocateResult();
        result.setTakeOrderMsg(takeOrderMsg);
        result.setAllocateMsg(allocateMsg);
        result.setSetUserMsg(setUserMsg);
        result.setUpdateOrderStatusMsg(updateOrderStatusMsg);
        result.setAllocatePrice(lastFee.toPlainString());

        return AjaxResult.success(result);
    } else {
        logger.error("用户所在部门dispatchMode配置错误，无法执行自动派单任务");
        throw new ServiceException("用户所在部门派单模式配置错误，联系管理员");
    }
}

private String getDeptDispatchMode(Long deptId) {
    SysDept dept = DeptService.selectDeptById(deptId);
    if (dept == null) {
        throw new RuntimeException("部门信息不存在");
    }
    return dept.getDispatchMode() != null ? dept.getDispatchMode() : "1";
}

//

/**
 * 接单成功后重试查询真实订单ID
 */
private String queryRealOrderIdWithRetry(OkHttpSessionClient client, String orderViewId, String gameName) {
    final int maxRetry = 10;
    final int retryIntervalMs = 1000; // 1秒

    for (int i = 0; i < maxRetry; i++) {
        try {
            String orderId = tryQueryRealOrderId(client, orderViewId, gameName);
            if (orderId != null) {
                return orderId;
            }
            logger.warn("第{}次查询真实订单ID未找到，等待{}ms后重试", i + 1, retryIntervalMs);
            Thread.sleep(retryIntervalMs);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException("查询真实订单ID时线程被中断", e);
        } catch (Exception e) {
            logger.error("查询真实订单ID时发生异常：{}", e.getMessage(), e);
            throw new RuntimeException("查询真实订单ID失败", e);
        }
    }
    throw new RuntimeException("接单成功但超时未查到真实订单ID，请稍后手动检查");
}

/**
 * 单次查询真实订单ID
 */
private String tryQueryRealOrderId(OkHttpSessionClient client, String orderViewId, String gameName) throws Exception {
    JDPCusQueryOrderParam query = new JDPCusQueryOrderParam();
    query.setKey1(orderViewId);
    query.setGameName(gameName);

    JSONObject response = mhJDPService.queryOrder(client, query);
    JSONArray dataArray = response.getJSONArray("data");
    if (dataArray != null && !dataArray.isEmpty()) {
        logger.info("查询到真实订单ID：{}", dataArray);
        return dataArray.getJSONObject(0).getString("orderId");
    }
    return null;
}


@PreAuthorize("@ss.hasPermi('order:allocate:list')")
@GetMapping("/list")
public TableDataInfo list(MhOrderAllocate mhOrderAllocate) {
    startPage();
    List<MhOrderAllocate> list = mhOrderAllocateService.resList(mhOrderAllocateService.selectMhOrderAllocateList(mhOrderAllocate), getUserId());
    return getDataTable(list);
}


/**
 * 导出订单指派列表
 */
@PreAuthorize("@ss.hasPermi('order:allocate:export')")
@Log(title = "订单指派", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MhOrderAllocate mhOrderAllocate) {
    //        如果是管理员登录，则返回所有数据
    Long userId = SecurityUtils.getUserId();
    if (!mhBindingServiceImpl.selectMhBindingByAdminId(userId).isEmpty()) {
        logger.info("管理员登录，返回所有数据{}", mhBindingServiceImpl.selectMhBindingByAdminId(userId));
        mhOrderAllocate.setRecManName(null);
    } else {
        logger.info("普通用户登录，返回当前用户数据{}", mhBindingServiceImpl.selectMhBindingByUserId(userId));
        String acc_name = mhBindingServiceImpl.selectMhBindingByUserId(userId).getSuUserName();
        mhOrderAllocate.setRecManName(acc_name);
        mhOrderAllocate.setRecManName(acc_name);
    }

    List<MhOrderAllocate> list = mhOrderAllocateService.resList(mhOrderAllocateService.selectMhOrderAllocateList(mhOrderAllocate), getUserId());
    ExcelUtil<MhOrderAllocate> util = new ExcelUtil<MhOrderAllocate>(MhOrderAllocate.class);
    util.exportExcel(response, list, "订单指派数据");
}

/**
 * 获取订单指派详细信息
 */
@PreAuthorize("@ss.hasPermi('order:allocate:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
    return success(mhOrderAllocateService.selectMhOrderAllocateById(id));
}

/**
 * 新增订单指派
 */
@PreAuthorize("@ss.hasPermi('order:allocate:add')")
@Log(title = "订单指派", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MhOrderAllocate mhOrderAllocate) {
    return toAjax(mhOrderAllocateService.insertMhOrderAllocate(mhOrderAllocate));
}

/**
 * 修改订单指派
 */
@PreAuthorize("@ss.hasPermi('order:allocate:edit')")
@Log(title = "订单指派", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MhOrderAllocate mhOrderAllocate) {
    return toAjax(mhOrderAllocateService.updateMhOrderAllocate(mhOrderAllocate));
}

/**
 * 删除订单指派
 */
@PreAuthorize("@ss.hasPermi('order:allocate:remove')")
@Log(title = "订单指派", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
    return toAjax(mhOrderAllocateService.deleteMhOrderAllocateByIds(ids));
}
}
